package com.dcw.lixb.designmode.flyweight;

import java.util.Random;

/**
 * @author lixiaobin
 * @date 2020-07-23 15:36:17
 * @desc 描述信息
 */
public class FlyweightMain {
    public static final String[] colors = {"红","黄","蓝","绿","紫","青","黑"};
    public static void main(String[] args) {
        for (int i = 0; i < 20; i++) {
            Circle circle = (Circle) ShapeFactory.getCircle(getRandomColor());
            circle.setRadius(getRandomInt());
            circle.setX(getRandomInt());
            circle.setY(getRandomInt());
            circle.draw();
        }
    }

    private static String getRandomColor() {
        return colors[(int)(Math.random()*colors.length)];
    }
    private static int getRandomInt() {
        return (int)(Math.random()*100 );
    }

}
